import axios from 'axios'

//每次发送的请求都会带一个/api
axios.defaults.baseURL = '/'
axios.defaults.headers['authorization'] = "myToken";
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'

// 请求拦截器
axios.interceptors.request.use(function(config) {
  config.headers['authorization'] = "new_myToken";
  //console.log("请求:",config);
  return config
}, function(error) {
  return Promise.reject(error)
})

// 响应拦截器
axios.interceptors.response.use(function (response) {
  console.log("响应数据:",response);
  //此处判断 code=未登录 跳转登录
  return response;
}, function (err) {
  console.log(err);
});
